<template>
  <div class="home-container">
    <div class="statusbar" v-if="showStatusBar">
      <div class="search-wrapper">
        <div @click="search" class="icon-button">
          <magnify-icon :size="26"></magnify-icon>
        </div>
      </div>
      <div class="tab-wrapper">
        <tab :active-color="colors.red" class="home-tabbar" :line-width="2" custom-bar-width="30px">
        <tab-item selected @on-item-click="onTabClicked('/home/heat')">热门</tab-item>
        <tab-item @on-item-click="onTabClicked('/home/weekfree')">周免</tab-item>
        <tab-item @on-item-click="onTabClicked('/home/competition')">攻略</tab-item>
        </tab>
      </div>
      <div class="search-wrapper">
        <div @click="search" class="icon-button">
          <bell-outline-icon :size="26"></bell-outline-icon>
        </div>
      </div>
    </div>
    <div class="main-content">
      <router-view></router-view>
    </div>
    
  </div>
</template>

<script>
import {colors} from '../../utils/theme'
export default {
  data () {
    return {
      colors,
      routeList: ['Heat','WeekFree','Competition'],
      searchDialog: ''
    }
  },
  computed: {
    showStatusBar(value) {
      return (this.routeList.indexOf(this.$route.name) !== -1)
    }
  },
  mounted() {
    // this.$router.push('/home/heat')
    // console.error(colors);
  },
  methods: {
    onTabClicked(tab) {
      this.$router.push(tab)
    },
    search() {
      this.searchDialog = true;
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
.home-container {
  width: 100%;
  height: 100%;
  position: relative;
}
.statusbar {
  background-color: white;
  position: fixed;
  z-index: 999;
  left: 0;
  top: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #eee;
  .search-wrapper {
    // flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 10%;
    flex-basis: 10%;
  }
  .tab-wrapper {
    // flex: 4;
    width: 40%;
    flex-basis: 40%;
  }
  .notification-wrapper {
    flex: 1;
  }
}
// 使内部路由界面完整显示
.main-content {
  margin-top: 36px;
  margin-bottom: 60px;
}
</style>
